WHAT IS HTML?
HTML stands for HyperText Markup Language.
It is used to create the structure of web pages.
HTML is not a programming language; it is a markup language that tells the browser how to display content.
Key points about HTML:
In short, HTML tells the browser what to show and how to show it.
HTML elements are the building blocks of a web page.
An element is made up of a start tag, some content, and an end tag.
Example of an HTML element:
<p>This is a paragraph</p>
This is a paragraph
Key points about HTML elements:
In short: HTML elements define the structure and content of a webpage.
Container elements are those HTML elements which have both an opening tag and a closing tag.
They "contain" some content inside them.
Example:
<p>This is a paragraph</p>
<div>This is a division block</div>
This is a paragraph
Key points about container elements:
In short: Container elements are used to wrap content inside them.
Empty elements are HTML elements that do not have a closing tag.
They are self-contained and are used to insert content or structure into the page without wrapping anything inside.
Examples of empty elements:
<br> - Inserts a line break <hr> - Inserts a horizontal rule <img src="lwa.jpg" alt="Example Image"> - Inserts an image
Line 1
Line 2 after break
Here is an image:
Key points about empty elements:
In short: Empty elements are self-contained tags that do not wrap any content.
HTML attributes give extra information about an element.
They are always written inside the opening tag in the format name="value".
Example:
<h1 align="center">Welcome</h1>
๐ In this example:
Key Points:
More Common Attributes:
<img src="lwa.jpg" alt="Website Logo" width="200"> <a href="https://www.example.com" target="_blank">Visit</a>
HTML tags are used to define elements on a webpage. They are usually written as <tagname>content</tagname>.
Common Basic HTML Tags:
<h1>This is a Heading 1</h1> <h2>This is a Heading 2</h2> <p>This is a paragraph.</p> <br> - Inserts a line break <hr> - Inserts a horizontal line <b>Bold Text</b> <i>Italic Text</i> <u>Underlined Text</u> <img src="lwa.jpg" alt="Logo">
This is a paragraph.
Line before break
Line after break
Bold Text
Italic Text
Underlined Text
Key Points:
The <basefont> tag was used to set a default font size, color, and face for the entire webpage.
Note: This tag is deprecated in HTML 4.01 and not supported in HTML5. It is recommended to use CSS instead.
<basefont size="4" color="blue" face="Arial"> <p>This paragraph will use the base font settings.</p>
This paragraph will use the base font settings.
Key Points:
body { font-family: Arial; color: blue; font-size: 16px; }The <!-- --> tag is used to add comments in HTML.
Comments are not displayed in the browser, but are visible in the source code.
They are useful for notes, explanations, or reminders in your HTML code.
<!-- This is a comment --> <p>This paragraph will be displayed.</p> <!-- Comments do not appear in the browser -->
This paragraph will be displayed.
Key Points:
Example Use: You can write reminders for yourself or explain complex parts of your code.
Purpose: Sets the background color of the page.
<body bgcolor="lightblue"> <h1>Welcome to My Website</h1> <p>This page has a light blue background.</p> </body>
This page has a light blue background.
Purpose: Sets the default text color for the page.
<body text="darkred"> <h1>Welcome</h1> <p>This text is dark red.</p> </body>
This text is dark red.
Purpose: Sets a background image for the page.
<body background="background.jpg"> <h1>My Website</h1> <p>This page has a background image.</p> </body>
This page has a background image.
Purpose: Set precise colors using hex codes for background and text.
<body bgcolor="#ffffe0" text="#00008b"> <h1>Hex Color Example</h1> <p>Background is light yellow, text is dark blue.</p> </body>
Background is light yellow, text is dark blue.
The margin is the space outside the element.
You can set margins using CSS inside the style attribute of the <body> tag.
<body style="margin-top:50px;"> <h1>Top Margin Example</h1> </body>
<body style="margin-bottom:50px;"> <h1>Bottom Margin Example</h1> </body>
<body style="margin-left:50px;"> <h1>Left Margin Example</h1> </body>
<body style="margin-right:50px;"> <h1>Right Margin Example</h1> </body>
<body style="margin:50px;"> <h1>All Sides Margin Example</h1> </body>
Text formatting tags are used to change the appearance or style of text in HTML.
Purpose: Sets font size, color, and face. (Deprecated in HTML5, use CSS instead)
<font color="blue" size="5" face="Arial">Hello World</font>
Purpose: Makes text bold.
<b>Bold Text</b>
Purpose: Makes text italic.
<i>Italic Text</i>
Purpose: Underlines the text.
<u>Underlined Text</u>
Purpose: Emphasizes text (usually italic).
<em>Emphasized Text</em>
Purpose: Highlights text.
<mark>Highlighted Text</mark>
Purpose: Makes text bold and indicates strong importance.
<strong>Strong Text</strong>
Purpose: Displays text in teletype or monospace font (deprecated).
<tt>Teletype Text</tt>
Purpose: Increases text size slightly.
<big>Big Text</big>
Purpose: Decreases text size slightly.
<small>Small Text</small>
Purpose: Displays text in preformatted form keeping spaces and line breaks.
<pre>
Line 1
Line 2 with spaces
Line 3
</pre>
Line 1
Line 2 with spaces
Line 3
Purpose: Creates a horizontal line to separate content. Here we make it more visible.
<h1>Before Line</h1> <hr style="height:5px; width:80%; background-color:#ff5733; border:none;"> <p>After Line</p>
After Line
Here I tell you all attributes of HR tag
Definition:
The align attribute is used to specify the alignment of text or elements inside certain HTML tags (like <p>, <h1>, <div>, etc.).
It defines whether the content should appear left, center, or right on the webpage.
Syntax:
<tagname align="value">Content</tagname>
Possible Values:
Note: The align attribute is not supported in modern HTML5 for most elements.
Itโs recommended to use CSS instead, for example:
style="text-align:center;"
<p style="text-align:center;">This text is centered using CSS.</p>
This text is centered using CSS.
Definition:
HTML provides six levels of heading tags โ from <h1> to <h6>.
Headings are used to define titles or subtitles on a webpage.
The <h1> tag represents the most important heading, and <h6> represents the least important.
Syntax:
<h1>Heading 1</h1> <h2>Heading 2</h2> <h3>Heading 3</h3> <h4>Heading 4</h4> <h5>Heading 5</h5> <h6>Heading 6</h6>
Explanation:
<h1>This is Heading 1</h1> <h2>This is Heading 2</h2> <h3>This is Heading 3</h3> <h4>This is Heading 4</h4> <h5>This is Heading 5</h5> <h6>This is Heading 6</h6>
Note: Search engines give more importance to <h1> tags. Itโs recommended to use only one <h1> tag per webpage for SEO purposes.
Definition:
HTML provides different tags to format text with strike-through, subscript, and superscript effects.
Syntax:
<strike>Text</strike> <sub>Text</sub> <sup>Text</sup>
<p>This is <strike>incorrect</strike> text.</p>
This is incorrect text.
<p>Water formula is H<sub>2</sub>O</p>
Water formula is H2O
<p>Square of 4 is 4<sup>2</sup> = 16</p>
Square of 4 is 42 = 16
Note:
The <strike> tag is deprecated in HTML5.
Use <del> or <s> instead for strike-through text.
Definition:
The <marquee> tag is used to create scrolling text or images on a webpage.
It scrolls the content horizontally or vertically within a defined area.
Note: The <marquee> tag is not supported in HTML5 โ use CSS animations instead.
Syntax:
<marquee attribute="value">Scrolling Text</marquee>
Common Attributes of <marquee>:
left, right, up, down.scroll, slide, alternate.infinite for continuous).<marquee>Welcome to HTML Marquee!</marquee>
<marquee direction="right">This text moves right</marquee> <marquee direction="up">This text moves upward</marquee>
<marquee behavior="alternate">This text bounces back and forth</marquee> <marquee behavior="slide">This text slides once and stops</marquee>
<marquee bgcolor="lightblue" scrollamount="10" width="400" height="50"> Colorful and Fast Scrolling Text </marquee>
Note:
The <marquee> tag is deprecated in HTML5.
Instead of using marquee, use CSS animations or JavaScript for scrolling effects.
Definition:
Lists in HTML are used to display information in an organized manner.
They help arrange items either in a numbered (ordered) or bulleted (unordered) format.
Thereโs also a definition list used to show terms and their descriptions.
Types of Lists:
Syntax:
<ol> <li>Item 1</li> <li>Item 2</li> </ol> <ul> <li>Item 1</li> <li>Item 2</li> </ul> <dl> <dt>Term</dt> <dd>Definition</dd> </dl>
<ol> <li>HTML</li> <li>CSS</li> <li>JavaScript</li> </ol>
Attribute: type โ Defines the numbering style (1, A, a, I, i).
<ol type="A"> <li>India</li> <li>USA</li> <li>Japan</li> </ol>
<ul> <li>Apple</li> <li>Mango</li> <li>Banana</li> </ul>
Attribute: type โ Defines the bullet style (disc, circle, square).
<ul type="square"> <li>C</li> <li>C++</li> <li>Python</li> </ul>
<dl> <dt>HTML</dt> <dd>A markup language for creating web pages.</dd> <dt>CSS</dt> <dd>Used for styling HTML elements.</dd> </dl>
Other Attributes:
<ol start="5"> <li>One</li> <li>Two</li> <li>Three</li> </ol> <ol reversed> <li>Red</li> <li>Green</li> <li>Blue</li> </ol>
Definition:
A table in HTML is used to display data in rows and columns.
It helps to organize information clearly โ for example, marks, prices, or schedules.
<table>
<caption>Student Marks</caption>
<tr>
<th>Name</th>
<th>Subject</th>
<th>Marks</th>
</tr>
<tr>
<td>Aman</td>
<td>Math</td>
<td>95</td>
</tr>
<tr>
<td>Riya</td>
<td>Science</td>
<td>88</td>
</tr>
</table>
| Name | Subject | Marks |
|---|---|---|
| Aman | Math | 95 |
| Riya | Science | 88 |
border="1").width="80%").
<table border="2" cellpadding="10" cellspacing="5" width="80%" align="center" bgcolor="#e6ffe6">
<caption>Employee Details</caption>
<tr bgcolor="#99ffcc">
<th>Name</th>
<th>Department</th>
<th>Salary</th>
</tr>
<tr>
<td>Rohit</td>
<td>IT</td>
<td>โน50,000</td>
</tr>
<tr>
<td>Neha</td>
<td>HR</td>
<td>โน45,000</td>
</tr>
</table>
| Name | Department | Salary |
|---|---|---|
| Rohit | IT | โน50,000 |
| Neha | HR | โน45,000 |
Note: In modern HTML, use CSS (like border-collapse, padding, and text-align) for better styling instead of old attributes.
Definition:
A table in HTML is used to display data in rows and columns.
Tables can have several attributes to style and format them.
Purpose: Sets the thickness of the table border.
<table border="3">
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
</table>
| Row 1, Cell 1 | Row 1, Cell 2 |
Purpose: Sets the background color of the table.
<table border="2" bgcolor="lightblue">
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
| Cell 1 | Cell 2 |
Purpose: Sets the color of the table border.
<table border="3" bordercolor="red">
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
| Cell 1 | Cell 2 |
Purpose: Sets an image as the background of the table.
<table border="2" background="background.jpg">
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
| Cell 1 | Cell 2 |
Purpose: Adds a title or caption to the table.
<table border="2">
<caption>Student Marks</caption>
<tr>
<td>Math</td>
<td>90</td>
</tr>
</table>
| Math | 90 |
Definition: The <caption> tag adds a title to the table. It appears above the table by default.
<table border="2">
<caption>Student Marks</caption>
<tr>
<td>Math</td>
<td>90</td>
</tr>
</table>
| Math | 90 |
Definition: The colspan attribute makes a cell span across multiple columns.
<table border="2">
<tr>
<td colspan="2">Name</td>
</tr>
<tr>
<td>First</td>
<td>Last</td>
</tr>
</table>
| Name | |
| First | Last |
Definition: The rowspan attribute makes a cell span across multiple rows.
<table border="2">
<tr>
<td rowspan="2">Subject</td>
<td>Marks</td>
</tr>
<tr>
<td>90</td>
</tr>
</table>
| Subject | Marks |
| 90 |
Definition: You can set background and text colors for rows, table headers, and table cells.
<table border="2">
<tr bgcolor="lightblue">
<th>Name</th>
<th>Score</th>
</tr>
<tr bgcolor="lightyellow">
<td>Ali</td>
<td>85</td>
</tr>
<tr bgcolor="lightgreen">
<td>Sara</td>
<td>92</td>
</tr>
</table>
| Name | Score |
|---|---|
| Ali | 85 |
| Sara | 92 |
Definition: A table inside another table is called a nested table. Useful for complex layouts.
<table border="2">
<tr>
<td>Student</td>
<td>
<table border="1">
<tr>
<td>Math</td>
<td>90</td>
</tr>
<tr>
<td>Science</td>
<td>95</td>
</tr>
</table>
</td>
</tr>
</table>
| Student |
|
Definition: The <img> tag is used to display images on a webpage. It is an empty tag (self-closing) and does not have a closing tag.
<img src="g.jpg" alt="Description">
Definition: Sets the width of the image in pixels (or percentage).
<img src="g.jpg" width="150">
Definition: Sets the height of the image in pixels (or percentage).
<img src="g.jpg" height="100">
Definition: Adds a border around the image. Deprecated in HTML5; use CSS instead.
<img src="g.jpg" border="5">
Definition: Aligns the image relative to surrounding text (left, right, middle). Deprecated in HTML5; CSS is recommended.
<img src="g.jpg" align="right" width="150">
This is some text before the image.
More text flows around the image.
Definition: Adds space around the image using hspace (horizontal) and vspace (vertical).
<img src="g.jpg" hspace="100" vspace="50" alt="Example Image">
Text before the image.
Text after the image. The spacing around the image is now moderate using hspace and vspace.
Definition: Provides alternative text displayed if the image cannot be loaded. Improves accessibility.
<img src="nonexistent.jpg" alt="Image not found">
Image not found
Definition: The <video> tag is used to embed video content in a webpage.
Common Attributes:
<video src="g.mp4" width="400" height="300" controls autoplay loop muted poster="g.jpg" preload="auto"> Your browser does not support the video tag. </video>
Notes:
Definition: The <audio> tag is used to embed audio content in a webpage.
Common Attributes:
<audio src="sample.mp3" controls> Your browser does not support the audio element. </audio>
Definition: The <a> tag is used to create hyperlinks in HTML. It allows users to navigate to another page, section, or website.
Common Attributes of <a>:
<a href="AI AND TECH.htm" target="_blank" title="Visit AI & TECH" rel="noopener"> AI & TECH </a>
Notes:
Definition: The <form> tag is used to create an HTML form to collect user input. Forms can include text fields, checkboxes, radio buttons, dropdowns, and more.
Common Attributes of <form>:
<form action="submit.php" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name"><br><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br><br> <label for="password">Password:</label> <input type="password" id="password" name="password"><br><br> <button type="submit">Register</button> </form>
Notes:
Definition: Single-line text input fields allow the user to enter text data.
<form>
Name: <input type="text" name="name">
</form>
Definition: Allows users to enter a password. Characters are hidden.
<form>
Password: <input type="password" name="password">
</form>
Definition: Used to enter multiple lines of text.
<form>
Address: <textarea name="address" rows="4" cols="30"></textarea>
</form>
Definition: Allows multiple selections from given options.
<form>
Hobbies:
<input type="checkbox" name="hobby" value="reading"> Reading
<input type="checkbox" name="hobby" value="music"> Music
</form>
Definition: Allows selecting only one option from a group.
<form>
Gender:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
</form>
Definition: Allows the user to select an option from a dropdown list.
<form>
Country:
<select name="country">
<option>India</option>
<option>USA</option>
<option>UK</option>
</select>
</form>
Definition: Buttons are used to submit or reset forms.
<form>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</form>
You have completed your HTML journey.
Keep practicing and building amazing webpages! ๐ป
For Learning more programming languages click More programming languages